<!--
 * @Author: g05047
 * @Date: 2021-06-01 15:03:16
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2021-07-26 09:01:12
 * @Description: file content
-->
<template>
  <div class="order-detail">
    <detailPageHeader title=" " :avatar="avatar" :orderId="nowDetail.workId" :type="nowDetail.workName" :statusName="nowDetail.statusName" :collect="collect" :leftType="leftType" @collect-order="onCollect">
      <a-descriptions slot="descriptions" style="width: 500px;margin-top:8px" v-if="taskType != 'advance' && taskType != 'paid_in'">
        <a-descriptions-item label="项目名称">{{ nowDetail.projectName }}</a-descriptions-item>
      </a-descriptions>
      <a-space slot="button" :size="12" v-if="leftType!='own_finsh'&&['add_cut','make_up','adjusted_basis'].includes(taskType)&&nowDetail.statusName!='已完成'&&nowDetail.buttonFlag!=9">
        <a-button type="primary" icon="check-circle" @click="onDeal">已处理</a-button>
        <a-button type="primary" icon="book" @click="onAbnormal">标记异常</a-button>
      </a-space>
      <a-space slot="button" :size="12" v-if="leftType!='own_finsh'&&taskType == 'error'&&nowDetail.buttonFlag!=9">
        <a-button type="primary" v-if="['社保补缴异常','公积金补缴异常'].includes(nowDetail.taskTypeName)" @click="onCancelTask">取消补缴</a-button>
        <a-button type="primary" v-if="['公积金调基异常','社保调基异常'].includes(nowDetail.taskTypeName)" @click="onCancelTask">取消调基</a-button>
        <a-button type="primary" icon="book" @click="onInfo">补充信息</a-button>
      </a-space>
      <a-space slot="button" :size="12" v-if="leftType!='own_finsh'&&taskType == 'paid_in'&&nowDetail.buttonFlag!=9">
        <a-button type="primary" :disabled="advancedCal" icon="upload" v-downLoad="{url: EXPORTSHIJIAOBILL+'?taskId='+id, name: '实缴账单导出.xlsx'}">账单导出</a-button>
        <a-button type="primary" @click="onRegenerate" icon="download" :disabled="advancedCal" v-if="nowDetail.buttonFlag=='0'">{{ advancedCal ? '正在计算中...' : '汇缴数据重新生成' }}</a-button>
        <a-popover placement="bottom">
          <template slot="content">
            <a class="ant-dropdown-link" style="display:block" v-if="nowDetail.buttonFlag=='0'">请款申请</a>
            <!-- <a class="ant-dropdown-link" style="display:block">撤回申请</a> -->
            <a class="ant-dropdown-link" style="display:block" @click="onImportModal" v-if="nowDetail.buttonFlag=='0'">导入调整数据</a>
            <a class="ant-dropdown-link" style="display:block" @click="onLockBill" v-if="nowDetail.buttonFlag=='0'">锁定账单</a>
          </template>
          <a-button type="primary" :disabled="advancedCal">
            更多操作
          </a-button>
        </a-popover>
      </a-space>
      <a-space slot="button" :size="12" v-if="leftType!='own_finsh'&&taskType == 'advance'&&nowDetail.buttonFlag!=9 ">
        <a-button type="primary" icon="upload" :disabled="advancedCal" v-downLoad="{url: EXPORTYUSHOUBILL+'?taskId='+id+'&keyword='+searchState.keyword, name: '预收账单导出模板.xlsx'}">账单导出</a-button>
        <a-button type="primary" icon="download" @click="onRegenerate" :disabled="advancedCal" v-if="nowDetail.buttonFlag=='0'">{{ advancedCal ? '正在计算中...' : '账单重新计算' }}</a-button>
        <a-popover placement="bottom">
          <template slot="content">
            <a class="ant-dropdown-link" style="display:block" @click="onImportModal" v-if="nowDetail.buttonFlag=='0'">导入调整金额</a>
            <a class="ant-dropdown-link" style="display:block" @click="onLockBill" v-if="nowDetail.buttonFlag=='0'">锁定账单</a>
          </template>
          <a-button type="primary" :disabled="advancedCal">
            更多操作
          </a-button>
        </a-popover>
      </a-space>
      <a-space slot="button" :size="12" v-if="leftType!='own_finsh'&&taskType == 'salary_tax'&&nowDetail.buttonFlag!=9">
        <a-button type="primary" icon="upload" @click="() => (window.location.href = nowDetail.origCompanyFile)">客户原件导出</a-button>
        <a-button type="primary" icon="download" @click="onImportModal('dryj')">客户原件导入</a-button>
        <a-popover placement="bottom">
          <template slot="content">
            <a class="ant-dropdown-link" style="display:block" v-if="nowDetail.buttonFlag == 'wait_import'" @click="onImportModal('dryf')">导入应发</a>
            <a class="ant-dropdown-link" style="display:block" v-if="nowDetail.buttonFlag == 'wait_cal_tax'" @click="onCalcTax">发起个税计算</a>
            <a class="ant-dropdown-link" style="display:block" v-if="nowDetail.buttonFlag == 'wait_return_tax'" @click="onLockPayTax">锁定账单</a>
            <a class="ant-dropdown-link" style="display:block" v-downLoad="{url: EXPORTXINSHUI+'?taskId='+id, name: '薪税账单导出模板.xlsx'}">导出账单</a>
          </template>
          <a-button type="primary">
            更多操作
          </a-button>
        </a-popover>
      </a-space>
    </detailPageHeader>
    <detailProgress :progressList="taskList" v-if="taskType != 'paid_in' && taskType != 'advance'"></detailProgress>
    <detailOperationRecord :operationRecords="operateLogList" :systemInfo="systemInfo" :addCutDataSource="socialAddData" :insured="insured" v-if="taskType != 'paid_in' && taskType != 'advance' && taskType != 'salary_tax'"></detailOperationRecord>
    <div v-if="taskType == 'paid_in'">
      <a-tabs :default-active-key="paidInTabIndex" @change="onPaidInChange">
        <a-tab-pane v-for="(tab, index) in qingkuanTab" :key="index" :tab="tab"></a-tab-pane>
      </a-tabs>
      <bill v-if="paidInTabIndex == 0" :statisticsList="sjstatisticsList" :columns="paidInSummaryParagraphColumns" :dataSource="qkhzdataSource" :innerColumns="paidInSummaryParagraphInnerColumns" type="qkhz"></bill>
      <bill v-if="[1,2].includes(paidInTabIndex)" :statisticsList="sjstatisticsList" :columns="paidInRemitAndAdjustColumns" :dataSource="paidInTabIndex == 1 ? hjmxdataSource : tzmxdataSource" :page="searchState.page" :pageSize="searchState.size" :total="total" @sizeChange="onSizeChange" @pageChange="onPageChange">
        <div slot="search">
          <a-form-model layout="inline" ref="searchToDo" name="searchToDo" style="margin-bottom: 24px">
            <a-form-model-item label="项目名称">
              <a-select show-search style="width: 140px" v-model="searchState.projectId" placeholder="项目名称" @search="onSearchProject" @change="onChangeProject" allow-clear>
                <a-select-option v-for="item in projectList" :key="item.projectId">{{ item.projectName }}</a-select-option>
              </a-select>
            </a-form-model-item>
            <a-form-model-item v-if="paidInTabIndex == 2" label="调整类型">
              <a-select v-model="searchState.adjustType" style="width: 140px" placeholder="调整类型" allow-clear>
                <a-select-option v-for="(item,index) in adjustList" :key="index+2" :value="index+2">{{ item }}</a-select-option>
              </a-select>
            </a-form-model-item>
            <a-form-model-item label="部门">
              <a-select show-search v-model="searchState.deptName" placeholder="部门" style="width: 140px" @search="onSearchDept" @change="onChangeDept">
                <a-select-option v-for="dept in deptList" :key="dept">
                  {{ dept }}
                </a-select-option>
              </a-select>
            </a-form-model-item>
            <a-form-model-item label="关键字">
              <a-input v-model="searchState.keyword" placeholder="请输入姓名/身份证号/手机号" allow-clear>
                <a-icon slot="prefix" type="user" />
              </a-input>
            </a-form-model-item>
            <a-form-model-item>
              <a-button type="primary" @click="onSearch">
                <a-icon type="search" />
                查询
              </a-button>
            </a-form-model-item>
          </a-form-model>
        </div>
      </bill>
      <detailOperationRecord :operationRecords="operateLogList" class="qingkuan" v-if="paidInTabIndex == 3"></detailOperationRecord>
    </div>
    <div v-if="taskType == 'advance' || taskType == 'salary_tax'">
      <a-tabs :default-active-key="advanceTabIndex" @change="onAdvanceChange" v-if="taskType == 'advance'">
        <a-tab-pane v-for="(tab, index) in advanceTab" :key="index" :tab="tab"></a-tab-pane>
      </a-tabs>
      <a-tabs :default-active-key="salaryTaxTabIndex" @change="onSalaryChange" v-if="taskType == 'salary_tax'">
        <a-tab-pane v-for="(tab, index) in xinziqingkuanTab" :key="index" :tab="tab"></a-tab-pane>
      </a-tabs>
      <bill v-if="(taskType == 'advance'&&advanceTabIndex==0)||(taskType == 'salary_tax'&&salaryTaxTabIndex==0)" :statisticsList="taskType == 'advance' ? zdstatisticsList : xzqkstatisticsList" :columns="taskType == 'advance' ? advanceBillColumns : salaryTaxColumns" :dataSource="taskType == 'advance' ? qkhzdataSource : xzqkdataSource" :page="searchState.page" :pageSize="searchState.size" :total="total" @sizeChange="onSizeChange" @pageChange="onPageChange">
        <div slot="search">
          <a-form-model layout="inline" ref="searchToDo" name="searchToDo" style="margin-bottom: 24px">
            <a-form-model-item label="关键字">
              <a-input style="width:245px" v-model="searchState.keyword" placeholder="请输入姓名/身份证号/手机号" allow-clear>
                <a-icon slot="prefix" type="user" />
              </a-input>
            </a-form-model-item>
            <a-form-model-item v-if="taskType == 'salary_tax'">
              <a-checkbox v-model="searchState.error" @change="onChangeError">
                <span style="color:red">{{errorTotal}}条</span>异常
              </a-checkbox>
              <a-checkbox v-model="searchState.unLock" @change="onChangeLock">
                <span style="color:red">{{unLockTotal}}条</span>个人社保公积金账单尚未锁定
              </a-checkbox>
            </a-form-model-item>
            <a-form-model-item>
              <a-button type="primary" @click="onSearch">
                <a-icon type="search" />
                查询
              </a-button>
            </a-form-model-item>
          </a-form-model>
        </div>
      </bill>
      <detailOperationRecord :operationRecords="operateLogList" class="advance" v-if="(taskType == 'advance'&&advanceTabIndex==1)||(taskType == 'salary_tax'&&salaryTaxTabIndex==1)"></detailOperationRecord>
    </div>
    <!-- 标记异常弹窗 -->
    <abnormalModal class="center-modal" :abnormalModal="abnormalModal" :taskErrorType="taskErrorType" @cancelModal="onCancelModal"></abnormalModal>
    <!-- 补充信息弹窗 -->
    <addInfoModal class="center-modal" :typeName="nowDetail.taskTypeName" :month="beginMonth+endMonth" :addInfoModal="addInfoModal" @cancelModal="onCancelModal"></addInfoModal>
    <!--导入调整金额  -->
    <a-modal :visible="resultModal" :afterClose="onAfterClose" title="导入" ok-text="下一步" @ok="onNext" @cancel="handleCancel" width="960px" :bodyStyle="{ height: '626px' }">
      <a-steps class="steps" :current="current">
        <a-step title="上传文件" description="导入数据" />
        <a-step title="执行导入" description="数据导入至服务器" />
        <a-step title="导入成功" description="完成数据导入" />
      </a-steps>
      <div class="content">
        <steps1 v-if="current === 1" @fileUrl="onFileUrl" @remove-file="onRemoveFile" :resultModal="resultModal">
          <template slot="official">
            <h3 style="font-weight: 550; margin-bottom: 20px">1. 下载模板</h3>
            <p>
              <a v-downLoad="{url: SHIJIAOIMPORTTEMPLATE, name: '实缴调整金额模板.xlsx'}" v-if="taskType=='paid_in'">点击下载模板</a>
              <a v-downLoad="{url: YUSHOUIMPORTTEMPLATE, name: '预收调整金额模板.xlsx'}" v-if="taskType=='advance'">点击下载模板</a>
              <a class="ant-dropdown-link" @click="onGetTemplate" v-if="salaryTaxImportType == 'dryf'">点击下载模板</a>
            </p>
            <h3 style="font-weight: 550; margin-bottom: 20px">2. 维护好后导入系统</h3>
          </template>
        </steps1>
        <steps2 v-if="current === 2" @importSuccess="onImportSuccess"></steps2>
        <steps3 v-if="current === 3" :fileUrl="fileUrl" :unAbnormalTotal="unAbnormalTotal" :abnormalTotal="abnormalTotal"></steps3>
      </div>
      <template slot="footer" v-if="current == 3">
        <a-button @click="handleCancel">取消</a-button>
        <a-button type="primary" @click="onImport">
          继续导入
        </a-button>
        <a-button type="primary" @click="onStepSure">
          确定
        </a-button>
      </template>
    </a-modal>
  </div>
</template>

<script>
import downLoad from '@/directive/down-load-url'
import detailPageHeader from './detail/detailPageHeader';
import detailProgress from './detail/detailProgress';
import detailOperationRecord from './detail/detailOperationRecord';
import addInfoModal from './modal/addInfoModal';
import abnormalModal from './modal/abnormalModal';
import bill from '@/pages/components/bill';
import steps1 from '@/pages/components/increasedWorkers/steps/steps1';
import steps2 from '@/pages/components/increasedWorkers/steps/steps2';
import steps3 from '@/pages/components/increasedWorkers/steps/steps3';
import { getSearchDept } from '@/services/project';
import { EXPORTYUSHOUBILL, EXPORTSHIJIAOBILL, EXPORTXINSHUI, SHIJIAOIMPORTTEMPLATE, YUSHOUIMPORTTEMPLATE, } from '@/services/api';
import { isNumber, regTest, getObjToArray } from '@/utils/util';
import { getTaxDetailList, getTaxImportTemplate, getTaxImportOriginal, getProjectSelectList, getShiJiaoSummary, getRemitDetail, getAdjustDetail, getRecount, getDetail, getCollect, getCancelCollect, getFinshTask, getMarkAbnormal, getCancelTask, getSupplementInfo, getLockBill, getYuShouDetailBill, getImportYuShou, getShiJiaoCount, getImportShijiao, getImportPayable, getTaxCalc, getTaxLockAndApply, } from '@/services/todo.js';
import datas from '@/utils/data';
export default {
  name: 'orderDetail',
  components: { detailPageHeader, detailProgress, detailOperationRecord, addInfoModal, abnormalModal, bill, steps1, steps2, steps3, },
  /**
   * @description:
   * @param {
   * id 待办id
   * taskType  判断是哪一种类型的待办详情
   * taskErrorType 异常类型列表
   * leftType 左侧导航类型
   * }
   * @return {*}
   */
  props: ['id', 'taskType', 'taskErrorType', 'leftType'],
  directives: { downLoad },
  data () {
    return {
      SHIJIAOIMPORTTEMPLATE, YUSHOUIMPORTTEMPLATE, EXPORTYUSHOUBILL, EXPORTSHIJIAOBILL, EXPORTXINSHUI,
      beginMonth: '',
      endMonth: '',
      advancedCal: false,
      unAbnormalTotal: '',
      abnormalTotal: '',
      failFileUrl: null,
      errorTotal: 0,
      unLockTotal: 0,
      fileUrl: '',
      paidInTabIndex: 0,
      advanceTabIndex: 0,
      salaryTaxTabIndex: 0,
      resultModal: false,
      addInfoModal: false,
      abnormalModal: false,
      avatar: 'http://tking-test.oss-cn-hangzhou.aliyuncs.com/compassCentral%2Forder_avatar.png',
      operateLogList: [],
      taskList: [],
      systemInfo: {},
      insured: {},
      nowDetail: {},
      collect: false,
      qingkuanTab: ['请款汇总', '汇缴明细', '调整明细', '操作记录'],
      advanceTab: ['账单', '操作记录'],
      xinziqingkuanTab: ['薪税明细', '操作记录'],
      sjstatisticsList: [],
      zdstatisticsList: [],
      xzqkstatisticsList: [],
      paidInSummaryParagraphColumns: datas.paidInSummaryParagraphColumns,
      paidInSummaryParagraphInnerColumns: datas.paidInSummaryParagraphInnerColumns,
      advanceBillColumns: datas.advanceBillColumns,
      paidInRemitAndAdjustColumns: datas.paidInRemitAndAdjustColumns,
      salaryTaxColumns: datas.salaryTaxColumns,
      xzqkdataSource: [],
      qkhzdataSource: [],
      hjmxdataSource: [],
      tzmxdataSource: [],
      projectList: [],
      deptList: [],
      adjustList: ['补缴', '补差', '退费', '补收', '预收'],
      searchState: {
        keyword: '',
        projectId: undefined,
        deptName: undefined,
        adjustType: undefined,
        employeeName: '', // 姓名
        employeeMobile: '', // 手机号
        employeeIdCard: '', // 身份证号码
        unLock: undefined,
        page: 1,
        size: 10,
        error: undefined,
      },
      current: 1,
      total: 0,
      socialAddData: [],
      salaryTaxImportType: '',
    };
  },
  methods: {
    /**
     * @description: 分页
     * @param {*} page
     * @param {*} pageSize
     * @return {*}
     */
    onPageChange (data) {
      this.searchState.page = data.page;
      this.searchState.size = data.pageSize;
      if (this.taskType == 'paid_in' && this.paidInTabIndex == 2) {
        this.getAdjustDetail(this.searchState);
      }
      if (this.taskType == 'paid_in' && this.paidInTabIndex == 1) {
        this.getRemitDetail(this.searchState);
      }
    },
    onSizeChange (data) {
      this.searchState.page = 1;
      this.searchState.size = data.size;
    },
    onOriginalExport () {
      console.log('原件导出');
    },
    onRemoveFile () {
      this.fileUrl = '';
    },
    onSearch () {
      if (this.taskType == 'advance') {
        this.getYuShouDetailBill({ taskId: this.id, keyword: this.searchState.keyword });
      }
      if (isNumber(this.searchState.keyword)) {
        if (regTest.mobileReg(this.searchState.keyword)) {
          this.searchState.employeeMobile = this.searchState.keyword;
        }
        if (regTest.idCardFifteen(this.searchState.keyword) || regTest.idCardEighteen(this.searchState.keyword)) {
          this.searchState.employeeIdCard = this.searchState.keyword;
        }
      } else {
        this.searchState.employeeName = this.searchState.keyword;
      }

      if (this.taskType == 'paid_in' && this.paidInTabIndex == 1) {
        this.getRemitDetail(this.searchState);
      } else if (this.taskType == 'paid_in' && this.paidInTabIndex == 2) {
        this.getAdjustDetail(this.searchState);
      }
      if (this.taskType == 'salary_tax') {
        const params1 = {
          id: this.id,
          pageNum: this.searchState.page,
          pageSize: this.searchState.size,
          keyword: this.searchState.keyword,
          modelType: 'N',
          isErrorFlag: this.searchState.error ? 1 : 0,
        };
        this.getTaxDetailList(params1);
      }
    },
    onStepSure () {
      this.current = 3;
      this.resultModal = false;
      this.$emit('closeDrawer', this.taskType);
    },
    onImport () {
      this.current = 1;
    },
    onAfterClose () {
      this.current = 1;
    },
    onImportSuccess () {
      this.current = 2;
    },
    onLockBill () {
      this.getLockBill({ taskId: this.id });
    },
    onImportModal (i) {
      if (this.taskType == 'salary_tax') {
        this.salaryTaxImportType = i;
      }
      this.resultModal = true;
    },
    onPaidInChange (index) {
      this.paidInTabIndex = index;
      this.searchState.taskId = this.id;
      if (this.paidInTabIndex == 0) {
        this.getShiJiaoSummary({ taskId: this.id });
      } else if (this.paidInTabIndex == 1) {
        this.getRemitDetail(this.searchState);
      } else if (this.paidInTabIndex == 2) {
        this.getAdjustDetail(this.searchState);
      }
      this.getDetail({ id: this.id });
    },
    onAdvanceChange (index) {
      this.advanceTabIndex = index;
      if (this.advanceTabIndex == 0) {
        this.getYuShouDetailBill({ taskId: this.id, keyword: this.searchState.keyword });
      }
      this.getDetail({ id: this.id });
    },
    onSalaryChange (index) {
      this.salaryTaxTabIndex = index;
      this.getDetail({ id: this.id });
      if (this.salaryTaxTabIndex == 0) {
        const params = {
          id: this.id,
          pageNum: this.searchState.page,
          pageSize: this.searchState.size,
          keyword: this.searchState.keyword,
          isErrorFlag: this.searchState.error ? 1 : 0,
        };
        this.getTaxDetailList({ ...params, modelType: 'Y' });
        this.getTaxDetailList({ ...params, modelType: 'N' });
      }
    },
    onAbnormal () {
      this.abnormalModal = true;
    },
    /**
     * @description: 导入应发-下载模板
     * @param {*}
     * @return {*}
     */
    onGetTemplate () {
      this.getTaxImportTemplate();
    },
    onNext () {
      if (!this.fileUrl) {
        this.$message.warning('请选择上传文件！');
        return;
      }
      if (this.current == 1) {
        if (this.taskType == 'advance') {
          this.getImportYuShou({ taskId: this.id, fileUrl: this.fileUrl });
        } else if (this.taskType == 'paid_in') {
          this.getImportShijiao({ taskId: this.id, fileUrl: this.fileUrl });
        } else if (this.taskType == 'salary_tax') {
          if (this.salaryTaxImportType == 'dryj') {
            this.getTaxImportOriginal({ taxBillId: this.nowDetail.taxBillId, origCompanyFilePath: this.fileUrl });
          } else {
            this.getImportPayable({ taxBillId: this.nowDetail.taxBillId, payableFilePath: this.fileUrl });
          }
        }
      }
      this.current = this.current + 1;
    },
    onFileUrl (url) {
      this.fileUrl = url;
    },
    handleCancel () {
      this.resultModal = false;
      this.current = 1;
    },
    onInfo () {
      this.addInfoModal = true;
    },
    onDeal () {
      this.getFinshTask({ id: this.id });
    },
    onCancelModal (result) {
      let { modal, str, data } = result;
      if (modal == '标记异常') {
        if (str == 'ok') {
          let { status, desc } = data;
          const params = { taskId: this.id, errorType: status, errorRemark: desc };
          this.getMarkAbnormal(params);
        }
        this.abnormalModal = false;
      } else {
        if (str == 'ok') {
          let { addInfoState } = data;
          let months;
          if (addInfoState.month) {
            months = [addInfoState.month].map(item => item.split('-').join(''));
          }
          if (addInfoState.makeUpMonth.length) {
            months = addInfoState.makeUpMonth.map(item => item.split('-').join(''));
          }
          const params = { taskId: this.id, months, fileUrls: addInfoState.fileUrls.map(item => item.url), memo: addInfoState.abnormal, };
          this.getSupplementInfo(params);
        }
        this.addInfoModal = false;
      }
    },
    /**
     * @description: 详情
     * @param {*}
     * @return {*}
     */
    getDetail (params) {
      getDetail(params).then(res => {
        let { code, data, msg } = res.data;
        if (code == 200) {
          this.nowDetail = data;
          this.operateLogList = data.operateLogList;
          this.operateLogList.forEach(val => {
            if (val.fileUploadUrls && val.fileUploadUrls.length) {
              let previewFile = [], type = '';
              val.fileUploadUrls.forEach((url, index) => {
                type = url.substring(url.lastIndexOf('.'))
                previewFile.push({ uid: index + 1, name: '文件' + (index + 1) + type, status: 'done', url, thumbUrl: url })
              })
              val.fileUploadUrls = previewFile
            }
          })
          this.taskList = data.taskList;
          this.taskList.forEach(val => {
            val.status = 'finish'
          })
          this.taskList[this.taskList.length - 1].status = 'wait'
          const system = this.operateLogList.filter(item => item.systemIf);
          if (!system[0].insured) {
            return;
          }
          this.insured = system[0].insured;
          this.beginMonth = this.insured.beginMonth ? this.insured.beginMonth.toString() : '';
          this.endMonth = this.insured.endMonth ? this.insured.endMonth.toString() : '';
          this.insured.makeUpMonths = system[0].makeUpMonths;
          if (this.nowDetail.taskTypeName == '社保增员' || this.nowDetail.taskTypeName == '社保增员异常') {
            this.systemInfo = this.getSocialAddArray(this.insured);
            const { personPension, compPension, personMedicalInsurance, compMedicalInsurance, personInjuryInsurance, compInjuryInsurance, personUnemploymentInsurance, compUnemploymentInsurance, personSeriousLlnessiMedical, compSeriousLlnessiMedical, personSupplementaryMedical, compSupplementaryMedical, personDisabilityFee, compDisabilityFee, personHeatingFee, compHeatingFee, } = this.insured;
            this.socialAddData = [
              {
                name: '个人缴纳基数',
                endowmentInsurance: personPension ? personPension : '',
                medicalInsurance: personMedicalInsurance ? personMedicalInsurance : '',
                unemploymentInsurance: personUnemploymentInsurance ? personUnemploymentInsurance : '',
                injuryInsurance: personInjuryInsurance ? personInjuryInsurance : '',
                seriousLlnessiMedical: personSeriousLlnessiMedical ? personSeriousLlnessiMedical : '',
                supplementaryMedical: personSupplementaryMedical ? personSupplementaryMedical : '',
                disabilityFee: personDisabilityFee ? personDisabilityFee : '',
                heatingFee: personHeatingFee ? personHeatingFee : '',
              },
              {
                name: '公司缴纳基数',
                endowmentInsurance: compPension ? compPension : '',
                medicalInsurance: compMedicalInsurance ? compMedicalInsurance : '',
                unemploymentInsurance: compUnemploymentInsurance ? compUnemploymentInsurance : '',
                injuryInsurance: compInjuryInsurance ? compInjuryInsurance : '',
                seriousLlnessiMedical: compSeriousLlnessiMedical ? compSeriousLlnessiMedical : '',
                supplementaryMedical: compSupplementaryMedical ? compSupplementaryMedical : '',
                disabilityFee: compDisabilityFee ? compDisabilityFee : '',
                heatingFee: compHeatingFee ? compHeatingFee : '',
              },
            ];
          } else if (this.nowDetail.taskTypeName == '公积金增员' || this.nowDetail.taskTypeName == '公积金增员异常') {
            this.systemInfo = this.getFundAddArray(this.insured);
          } else if (this.nowDetail.taskTypeName == '公积金减员' || this.nowDetail.taskTypeName == '社保减员' || this.nowDetail.taskTypeName == '公积金减员异常' || this.nowDetail.taskTypeName == '社保减员异常') {
            this.systemInfo = this.getSocialAndFundCutArray(this.insured);
          } else if (this.nowDetail.taskTypeName == '公积金补缴' || this.nowDetail.taskTypeName == '社保补缴' || this.nowDetail.taskTypeName == '公积金补缴异常' || this.nowDetail.taskTypeName == '社保补缴异常') {
            this.systemInfo = this.getMakeUpArray(this.insured);
          } else if (this.nowDetail.taskTypeName == '公积金调基' || this.nowDetail.taskTypeName == '公积金调基异常') {
            this.systemInfo = this.getAdjustedBasisArrayg(this.insured);
          } else if (this.nowDetail.taskTypeName == '社保调基' || this.nowDetail.taskTypeName == '社保调基异常') {
            this.systemInfo = this.getAdjustedBasisArrays(this.insured);
          }
        } else {
          this.$message.error(msg);
        }
      });
    },
    /**
     * @description: 操作记录-社保增员
     * @param {*}
     * @return {*}
     */
    getSocialAddArray (obj) {
      const arr1 = ['姓名', '身份证号', '手机号', '服务类型', '参保地', '开始缴纳月份', '户籍地址', '户籍属性'];
      const arr2 = ['name', 'idcard', 'mobile', 'taskName', 'cityName', 'beginMonth', 'census', 'category'];
      return getObjToArray(arr1, arr2, obj)
    },
    /**
     * @description: 操作记录-社保减员/公积金减员
     * @param {*}
     * @return {*}
     */
    getSocialAndFundCutArray (obj) {
      const arr1 = ['姓名', '身份证号', '手机号', '服务类型', '参保地', '停止缴纳月份'];
      const arr2 = ['name', 'idcard', 'mobile', 'taskName', 'cityName', 'endMonth']
      return getObjToArray(arr1, arr2, obj)
    },
    /**
     * @description: 操作记录-公积金增员
     * @param {*}
     * @return {*}
     */
    getFundAddArray (obj) {
      const arr1 = ['姓名', '身份证号', '手机号', '服务类型', '参保地', '开始缴纳月份', '户籍地址', '户籍属性', '个人缴纳基数', '公司缴纳基数', '个人公积金比例', '公司公积金比例']
      const arr2 = ['name', 'idcard', 'mobile', 'taskName', 'cityName', 'beginMonth', 'census', 'category', 'personBaseAmt', 'companyBaseAmt', 'personPayPercent', 'companyPayPercent']
      return getObjToArray(arr1, arr2, obj)
    },
    /**
     * @description: 操作记录-补缴详情
     * @param {*}
     * @return {*}
     */
    getMakeUpArray (obj) {
      const arr1 = ['姓名', '身份证号', '手机号', '服务类型', '参保地', '开始缴纳月份', '补缴月份']
      const arr2 = ['name', 'idcard', 'mobile', 'taskName', 'cityName', 'beginMonth', 'makeUpMonths']
      return getObjToArray(arr1, arr2, obj)
    },
    /**
     * @description: 操作记录-调基详情-公积金调基
     * @param {*}
     * @return {*}
     */
    getAdjustedBasisArrayg (obj) {
      const arr1 = ['姓名', '身份证号', '手机号', '服务类型', '参保地', '开始缴纳月份', '参保方案', '公积金基数']
      const arr2 = ['name', 'idcard', 'mobile', 'taskName', 'cityName', 'beginMonth', 'policyName', 'personBaseAmt']
      return getObjToArray(arr1, arr2, obj)
    },
    /**
     * @description: 操作记录-调基详情-社保调基
     * @param {*}
     * @return {*}
     */
    getAdjustedBasisArrays (obj) {
      const arr1 = ['姓名', '身份证号', '手机号', '服务类型', '参保地', '开始缴纳月份', '参保方案', '社保基数']
      const arr2 = ['name', 'idcard', 'mobile', 'taskName', 'cityName', 'beginMonth', 'policyName', 'compMedicalInsurance']
      return getObjToArray(arr1, arr2, obj)
    },
    /**
     * @description: 收藏
     * @param {*}
     * @return {*}
     */
    onCollect (data) {
      if (data) {
        this.getCollect({ id: this.id });
        this.collect = true;
      } else {
        this.getCancelCollect({ id: this.id });
        this.collect = false;
      }
    },
    getCollect (params) {
      getCollect(params).then(res => {
        let { code, msg } = res.data;
        if (code == 200) {
          this.$message.success('收藏成功！');
        } else {
          this.$message.error(msg);
        }
      });
    },
    /**
     * @description: 取消收藏
     * @param {*}
     * @return {*}
     */
    getCancelCollect (params) {
      getCancelCollect(params).then(res => {
        let { code, msg } = res.data;
        if (code == 200) {
          this.$message.success('取消收藏成功！');
        } else {
          this.$message.error(msg);
        }
      });
    },
    /**
     * @description: 完成待办
     * @param {*}
     * @return {*}
     */
    getFinshTask (params) {
      getFinshTask(params).then(res => {
        let { code, msg } = res.data;
        if (code == 200) {
          this.$message.success('已完成！');
          this.$emit('closeDrawer', this.taskType);
        } else {
          this.$message.error(msg);
        }
      });
    },
    /**
     * @description: 标记异常
     * @param {*}
     * @return {*}
     */
    getMarkAbnormal (params) {
      getMarkAbnormal(params).then(res => {
        let { code, msg } = res.data;
        if (code == 200) {
          this.$emit('closeDrawer', this.taskType);
        } else {
          this.$message.error(msg);
        }
      });
    },
    /**
     * @description: 取消补缴/调基
     * @param {*}
     * @return {*}
     */
    getCancelTask (params) {
      getCancelTask(params).then(res => {
        let { code, msg } = res.data;
        if (code == 200) {
          this.$emit('closeDrawer', this.taskType);
        } else {
          this.$message.error(msg);
        }
      });
    },
    onCancelTask () {
      this.getCancelTask({ taskId: this.id });
    },
    /**
     * @description: 补充增减员/补缴/调基信息
     * @param {*}
     * @return {*}
     */
    getSupplementInfo (params) {
      getSupplementInfo(params).then(res => {
        let { code, msg } = res.data;
        if (code == 200) {
          this.$emit('closeDrawer', this.taskType);
        } else {
          this.$message.error(msg);
        }
      });
    },
    /**
     * @description: 锁定账单
     * @param {*}
     * @return {*}
     */
    getLockBill (params) {
      getLockBill(params).then(res => {
        let { code, msg } = res.data;
        if (code == 200) {
          this.$message.success('账单锁定成功！');
          this.$emit('closeDrawer', this.taskType);
          this.advancedCal = true;
        } else {
          this.$message.error(msg);
        }
      });
    },
    /**
     * @description: 预收账单详情-账单
     * @param {*}
     * @return {*}
     */
    getYuShouDetailBill (params) {
      getYuShouDetailBill(params).then(res => {
        let { code, data, msg } = res.data;
        if (code == 200) {
          const arr = this.getYuShouStatisticArray(data);
          this.zdstatisticsList = arr;
          this.qkhzdataSource = data.detailList;
        } else {
          this.$message.error(msg);
        }
      });
    },
    /**
     * @description: 导入预收
     * @param {*}
     * @return {*}
     */
    getImportYuShou (params) {
      getImportYuShou(params).then(res => {
        let { code, data, msg } = res.data;
        if (code == 200) {
          this.unAbnormalTotal = data.total;
          this.abnormalTotal = data.fail;
          this.failFileUrl = data.failFileUrl;
        } else {
          this.$message.error(msg);
        }
      });
    },
    /**
     * @description: 预收详情-账单-统计
     * @param {*}
     * @return {*}
     */
    getYuShouStatisticArray (obj) {
      const arr1 = ['雇员数量', '社保', '公积金', '调整金额合计', '合计']
      const arr2 = ['calDetailCount', 'socialSum', 'fundSum', 'billAdjustSum', 'billSum']
      return getObjToArray(arr1, arr2, obj)
    },
    /**
     * @description: 实缴统计
     * @param {*}
     * @return {*}
     */
    getShiJiaoStatisticArray (obj) {
      const arr1 = ['雇员数量', '社保', '公积金', '合计']
      const arr2 = ['employeeCount', 'sociaCount', 'fundCount', 'totalCount']
      return getObjToArray(arr1, arr2, obj)
    },
    /**
     * @description: 薪税明细统计
     * @param {*}
     * @return {*}
     */
    getTaxStatisticArray (obj) {
      const arr1 = ['雇员数量', '应发工资合计', '个税合计']
      const arr2 = ['employeeTotal', 'salaryTotal', 'personTaxTotal']
      return getObjToArray(arr1, arr2, obj)
    },
    /**
     * @description: 重新计算
     * @param {*}
     * @return {*}
     */
    getRecount (params) {
      getRecount(params).then(res => {
        let { code, msg } = res.data;
        if (code == 200) {
          this.advancedCal = false;
          this.$message.success("数据已重新生成！")
        } else {
          this.$message.error(msg);
        }
      });
    },
    onRegenerate () {
      this.advancedCal = true
      this.getRecount({ taskId: this.id });
    },
    /**
     * @description: 实缴详情-请款汇总
     * @param {*}
     * @return {*}
     */
    getShiJiaoSummary (params) {
      getShiJiaoSummary(params).then(res => {
        let { code, data, msg } = res.data;
        if (code == 200) {
          this.qkhzdataSource = data;
        } else {
          this.$message.error(msg);
        }
      });
    },
    /**
     * @description: 实缴详情-汇缴明细
     * @param {*}
     * @return {*}
     */
    getRemitDetail (params) {
      getRemitDetail(params).then(res => {
        let { code, data, msg } = res.data;
        if (code == 200) {
          this.hjmxdataSource = data.content;
          this.total = data.totalElements;
        } else {
          this.$message.error(msg);
        }
      });
    },
    /**
     * @description: 实缴详情-调整明细
     * @param {*}
     * @return {*}
     */
    getAdjustDetail (params) {
      getAdjustDetail(params).then(res => {
        let { code, data, msg } = res.data;
        if (code == 200) {
          this.tzmxdataSource = data.content;
          this.total = data.totalElements;
        } else {
          this.$message.error(msg);
        }
      });
    },
    /**
     * @description: 实缴详情-项目下拉列表
     * @param {*}
     * @return {*}
     */
    getProjectSelectList (params) {
      getProjectSelectList(params).then(res => {
        let { code, data, msg } = res.data;
        if (code == 200) {
          this.projectList = data;
        } else {
          this.$message.error(msg);
        }
      });
    },
    onSearchProject (value) {
      if (value.length >= 2) {
        this.getProjectSelectList({ projectName: value });
      }
    },
    onChangeProject (val) {
      this.searchState.projectId = val;
    },
    /**
     * @description: 搜索部门列表
     * @param {*}
     * @return {*}
     */
    onSearchDept (value) {
      if (value.length >= 2) {
        this.getSearchDept({ deptName: value });
      }
    },
    onChangeDept (value) {
      this.searchState.deptName = value;
    },
    getSearchDept (params) {
      getSearchDept(params).then(res => {
        let { code, data, msg } = res.data;
        if (code == 200) {
          this.deptList = data;
        } else {
          this.$message.error(msg);
        }
      });
    },
    /**
     * @description: 实缴详情-统计
     * @param {*}
     * @return {*}
     */
    getShiJiaoCount (params) {
      getShiJiaoCount(params).then(res => {
        let { code, data, msg } = res.data;
        if (code == 200) {
          const arr = this.getShiJiaoStatisticArray(data);
          this.sjstatisticsList = arr;
        } else {
          this.$message.error(msg);
        }
      });
    },
    /**
     * @description: 导入实缴
     * @param {*}
     * @return {*}
     */
    getImportShijiao (params) {
      getImportShijiao(params).then(res => {
        let { code, data, msg } = res.data;
        if (code == 200) {
          this.unAbnormalTotal = data.total;
          this.abnormalTotal = data.fail;
          this.failFileUrl = data.failFileUrl;
        } else {
          this.$message.error(msg);
        }
      });
    },
    /**
     * @description: 薪税导入原件
     * @param {*}
     * @return {*}
     */
    getTaxImportOriginal (params) {
      getTaxImportOriginal(params).then(res => {
        let { code, data, msg } = res.data;
        if (code == 200) {
          this.$message.success('导入成功！');
          this.$emit('closeDrawer', this.taskType);
        } else {
          this.$message.error(msg);
        }
      });
    },
    /**
     * @description: 获取导入模板--薪税
     * @param {*}
     * @return {*}
     */
    getTaxImportTemplate (params) {
      getTaxImportTemplate(params).then(res => {
        let { code, data, msg } = res.data;
        if (code == 200) {
          window.location.href = data;
        } else {
          this.$message.error(msg);
        }
      });
    },
    /**
     * @description: 薪税请款-薪税明细
     * @param {*}
     * @return {*}
     */
    getTaxDetailList (params) {
      getTaxDetailList(params).then(res => {
        let { code, data, msg } = res.data;
        if (code == 200) {
          if (data.detail) {
            this.xzqkdataSource = data.detail.content;
            this.total = data.detail.totalElements;
          }
          const { employeeTotal, salaryTotal, personTaxTotal } = data;
          this.xzqkstatisticsList = this.getTaxStatisticArray({ employeeTotal, salaryTotal, personTaxTotal });
        } else {
          this.$message.error(msg);
        }
      });
    },
    onChangeError () {
      const params = {
        id: this.id,
        pageNum: this.searchState.page,
        pageSize: this.searchState.size,
        keyword: this.searchState.keyword,
        modelType: this.searchState.error ? 'N' : 'Y',
        isErrorFlag: this.searchState.error ? 1 : 0,
      };
      this.getTaxDetailList(params);
    },
    onChangeLock () {
      console.log(this.searchState);
    },
    /**
     * @description: 薪税请款-导入应发
     * @param {*}
     * @return {*}
     */
    getImportPayable (params) {
      getImportPayable(params).then(res => {
        let { code, data, msg } = res.data;
        if (code == 200) {
          this.$message.success("导入成功！")
        } else {
          this.$message.error(msg);
        }
      });
    },
    /**
     * @description: 薪税请款-发起个税计算
     * @param {*}
     * @return {*}
     */
    getTaxCalc (params) {
      getTaxCalc(params).then(res => {
        let { code, data, msg } = res.data;
        if (code == 200) {
          this.$message.success("成功发起个税计算")
        } else {
          this.$message.error(msg);
        }
      });
    },
    onCalcTax () {
      this.getTaxCalc({ taxBillId: this.nowDetail.taxBillId });
    },
    /**
     * @description: 薪税请款-锁定并申报
     * @param {*}
     * @return {*}
     */
    getTaxLockAndApply (params) {
      getTaxLockAndApply(params).then(res => {
        let { code, data, msg } = res.data;
        if (code == 200) {
          this.$emit('closeDrawer', this.taskType);
        } else {
          this.$message.error(msg);
        }
      });
    },
    onLockPayTax () {
      this.getTaxLockAndApply({ taxBillId: this.nowDetail.taxBillId });
    },
  },
  mounted () {
    this.getDetail({ id: this.id });
    if (this.taskType == 'advance') {
      this.getYuShouDetailBill({ taskId: this.id, keyword: this.searchState.keyword });
    } else if (this.taskType == 'paid_in') {
      this.getShiJiaoCount({ taskId: this.id }); // 統計
      this.getShiJiaoSummary({ taskId: this.id }); // 请款汇总
    } else if (this.taskType == 'salary_tax') {
      const params = {
        id: this.id,
        pageNum: this.searchState.page,
        pageSize: this.searchState.size,
        keyword: this.searchState.keyword,
        isErrorFlag: this.searchState.error ? 1 : 0,
      };
      this.getTaxDetailList({ ...params, modelType: 'Y' });
      this.getTaxDetailList({ ...params, modelType: 'N' });
    }
  },
};
</script>

<style lang="less" scoped>
/deep/ .qingkuan.ant-card .ant-card-head,
/deep/ .advance.ant-card .ant-card-head {
  display: none !important;
}
.order-detail {
  /deep/ .ant-card-head {
    padding: 0;
  }
}
</style>
